import Data.List
import Data.Maybe

findDirt :: [String] -> (Int, Int)
findDirt (x:xs) = if foundDirt then (row, column) else findDirt xs
    where dirtInThisRow = elemIndex 'd' x 
          foundDirt = isJust dirtInThisRow 
          row = 4 - length xs 
          column = fromJust dirtInThisRow
          

nextMove :: (Int, Int) -> [String] -> String
nextMove x ys = if isAbove 
                   then "CLEAN"
                   else if isUp 
                           then "UP"
                           else if isRight
                                   then "RIGHT"  
                                   else if isLeft
                                           then "LEFT"
                                           else "DOWN" 
    where botRow = fst x
          botColumn = snd x
          dirtPos = findDirt ys
          dirtRow = fst dirtPos
          dirtColumn = snd dirtPos
          isAbove = botRow == dirtRow && botColumn == dirtColumn
          isUp = botRow > dirtRow
          isRight = botColumn < dirtColumn
          isLeft = botColumn > dirtColumn

    --logic here
main :: IO()
main = do
    c <- getContents
    let ls = lines c
        ys = words $ head ls
        pos = (read (head ys), read (last ys))
        board = tail ls
    putStrLn $ nextMove pos board
